package linuxbox.bbs.exception;

import java.io.*;

public class BbsException extends Exception
{
  private boolean m_bLog = true;
  
	public BbsException()
	{
		super();
	}
	public BbsException(String msg)
	{
		super(msg);

    if ( m_bLog )
    {
		  try
		  {
			  FileOutputStream log = new FileOutputStream("/bbs_err.log", false);//true);
        PrintWriter writer = new PrintWriter(log);
        writer.println(msg);
        this.printStackTrace(writer);
        writer.close();
        log.close();
		  }
		  catch(IOException e)
		  {
  			System.out.println("Can not create log: " + e.getMessage() );
        System.out.println("Error message:" + msg);
		  }
    }
	}
  public void EnableLog(boolean b)
  {
    m_bLog = b;
  }
  public boolean IsLogEnabled()
  {
    return m_bLog;
  }
}
